package com.junmo.fanbizhidemo.demoview;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import com.junmo.fanbizhidemo.R;
import com.junmo.fanbizhidemo.adapter.BaseRecyclerAdapter;
import com.junmo.fanbizhidemo.adapter.HengXiangAdapter;
import com.junmo.fanbizhidemo.back.HorizontalPageLayoutManager;
import com.junmo.fanbizhidemo.back.PagingScrollHelper;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class HengXiangActivity extends Activity {
    @BindView(R.id.text_list)
    RecyclerView textList;

    private HengXiangAdapter adapter;
    private List<String> mList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_heng_xiang);
        ButterKnife.bind(this);
        restatat();
    }


    private void restatat() {

        //构造HorizontalPageLayoutManager,传入行数和列数
        HorizontalPageLayoutManager horizontalPageLayoutManager = new HorizontalPageLayoutManager(1, 5);
        textList.setLayoutManager(horizontalPageLayoutManager);
        mList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            mList.add(i + "月");
        }
        adapter = new HengXiangAdapter();
        adapter.setmDatas(mList);
        textList.setAdapter(adapter);
        adapter.setOnItemClickListener(new BaseRecyclerAdapter.onItemClickListener() {
            @Override
            public void onItemClick(int position, Object data) {
                Toast.makeText(HengXiangActivity.this,position+"",Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onItemLongClick(int position, Object data) {

            }
        });
        PagingScrollHelper scrollHelper = new PagingScrollHelper();
        scrollHelper.setUpRecycleView(textList);
        //设置页面滚动监听
        scrollHelper.setOnPageChangeListener(new PagingScrollHelper.onPageChangeListener() {
            @Override
            public void onPageChange(int index) {

            }
        });
    }
}
